package com.ease.map.rule {
   import com.ease.map.common.basetype.hashmap.HashMap;
   import com.ease.map.common.util.Evals;
   import com.ease.map.rule.IRule;
   
   import flash.utils.Dictionary;

   /**
    * 规则
    * 支持样式规则、标注规则
    */
   public class Rule implements IRule {
      /**规则条件数组，(filter条件,object)*/
      private var _expressionFilterDic:Dictionary;
	 //暂时为hashmap
	  private var _styleMap:HashMap;

      public function Rule(filterDic:Dictionary = null) {
         _expressionFilterDic = filterDic;
      }

      /**
       * 根据fieldsMap以及expressionFilterDic获取满足条件的style或label
       */
      public function getRightObject(fieldsMap:Object):Object {
         if (!fieldsMap) {
            return null;
         }

         //遍历dictionary，满足条件就退出
         for (var key:String in expressionFilterDic) {
            if (Evals.evalToBoolean(fieldsMap, key)) {
               return this.expressionFilterDic[key];
            }
         }
         return null;
      }

      public function get expressionFilterDic():Dictionary {
         return _expressionFilterDic;
      }

      /**
       * @private
       */
      public function set expressionFilterDic(value:Dictionary):void {
         _expressionFilterDic = value;
      }

      public function clone():IRule {
         return new Rule(this.expressionFilterDic);
      }

   }
}